#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QVariant>
#include <QTextDocument>
#include <QTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QListWidget>
#include <QDockWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QToolButton>
#include <QReadWriteLock>
#include <QPointer>

#include "preferenceswindow.h"

//#include <OSCthulhuClient.h>

class OSCthulhuClient;

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    void addChatLine( QString line );
    void setUserName( QString uN );
    void setClient( OSCthulhuClient* c );
    void addPort(int portNumber);
    void resetPortList();
    QString getChatText();

public slots:
    void addPeer(QString userName);
    void removePeer(QString userName);
    void addSyncObject(QString name);
    void removeSyncObject(QString name,QString type,QString subType);
    void addSyncArg(QString name,int argNum,QVariant argValue);
    void setSyncArg(QString name,int argNum,QVariant argValue);
    void submitChatLine();
    void printObject(QString name, QStringList arguments);
    void removePrintObject(QString name);
    void openObjectPrintWindow();
    void printOSC(QString message);
    void openOSCPrintWindow();
    QToolButton* getFlushButton();
    void changeUserPiece(QString userName, QString piece);

signals:
    void chatTextChanged( QString line );
    void setObjectPrint(bool printing);
    void setOSCPrint(bool printing);
    void flush();
public slots:
    void flushSig();
    void disconnected();
    void connected();
    void toggleOptionsWindow();

private:
    QString userName;
    OSCthulhuClient* client;
    QLineEdit chatInput;
    QToolButton flushButton, objectPrintButton, oscPrintButton;
    QListWidget portList;
    QLabel chatLabel, usersLabel, portsLabel, objectsLabel;
    QListWidget listWidget, listWidget2, objectPrintPanel;
    QTextEdit textEdit, oscPrintPanel;
    QString windowStyleSheet;
    QDockWidget objectPrintWindow, oscPrintWindow;
    bool objectPrinting, oscPrinting;
    QReadWriteLock objectLock,peerlock,printObjectLock;
    QToolButton connectionButton;
    QPointer<PreferencesWindow> preferencesWindow;
    QToolButton optionsButton;
};

#endif // MAINWINDOW_H
